package com.lt.flashcard.model.service;

import org.bson.types.ObjectId;

import com.google.code.morphia.Morphia;
import com.google.code.morphia.dao.BasicDAO;
import com.google.code.morphia.query.Query;
import com.lt.flashcard.model.entity.Vote;
import com.mongodb.Mongo;

public class VoteService extends BasicDAO<Vote, ObjectId>{
	protected VoteService(Mongo mongo, Morphia morphia) {
        super(mongo, morphia, Repository.DB_NAME);
    }
	
	/**
	 * Get rating of user for an element
	 * @param userid
	 * @param eid element id
	 * @param type the element type
	 * @return
	 */
	public Vote getVote(Long userid, Long eid, int type) {
		Query<Vote> query = createQuery();
		query.field("uid").equal(userid);
		query.field("fsid").equal(eid);
		return query.get();
	}
}
